  <script type = "text/javascript"> 
 
// Note: Like all Javascript password scripts, this is hopelessly insecure as the user can see 
//the valid usernames/passwords and the redirect url simply with View Source.  
// And the user can obtain another three tries simply by refreshing the page.  
//So do not use for anything serious!
 
var count = 2;
function validate() {
var un = document.myform.username.value;
var pw = document.myform.pword.value;
var valid = false;
 
var unArray = ["test", "Philip", "George", "Sarah", "Michael"];  // as many as you like - no comma after final entry
var pwArray = ["test", "Password1", "Password2", "Password3", "Password4"];  // the corresponding passwords;
 
for (var i=0; i <unArray.length; i++) {
if ((un == unArray[i]) && (pw == pwArray[i])) {
valid = true;
break;
}
}
 
if (valid) {
alert ("Login was successful");
window.location = "protected.html";
return false;
}
 
var t = " tries";
if (count == 1) {t = " try"}
 
if (count >= 1) {
alert ("Invalid username and/or password.  You have " + count + t + " left.");
document.myform.username.value = "";
document.myform.pword.value = "";
setTimeout("document.myform.username.focus()", 25);
setTimeout("document.myform.username.select()", 25);
count --;
}
 
else {
alert ("Still incorrect! You have no more tries left!");
document.myform.username.value = "Refresh to try again";
document.myform.pword.value = "";
document.myform.username.disabled = true;
document.myform.pword.disabled = true;
return false;
}
 
}
 
</script>
   <form name = "myform">
<p align="left"><span class="style11">ENTER USER NAME
  <input type="text" name="username">
</span>  <span class="style11">ENTER PASSWORD</span>  
 
  <input type="password" name="pword">
</p>
<p align="center" class="style13"> <a href="signup.html">Sign Up</a> | <a href="resetpassword.html">Have you forgotten your password?</a></p>
<p align="right">
  <input type="button" value="Login" name="Submit" onClick= "validate()">
</p>
 </form>
